<{include file="public/member_header" /}>
<script type="text/javascript">
 // 解码  
	function decode( str ){
		var div = document.createElement('div');
		div.innerHTML = str;
		return div.innerHTML;
	}
    $(function() {
        var uploader = new plupload.Uploader({
            drop_element : 'container',
            runtimes: 'html5,flash,silverlight,html4',
            browse_button: 'uploadstart',
            container: document.getElementById('container'),
            url : '<{:url('upload')}>',
            flash_swf_url : '__STATIC__/plupload/js/Moxie.swf',
            silverlight_xap_url : '__STATIC__/plupload/js/Moxie.xap',
            filters: {
                max_file_size: '5mb',
				/*
                mime_types: [{
                    title: "文档上传"
                    ,extensions: "docx"//"doc,docx,txt"
                }]*/
            },
            multi_selection : false,
            init : {
                PostInit: function() {},
                FilesAdded: function(up, files) {
                    uploader.start();
                },
                BeforeUpload: function(up, files) {
                    //console.log(up);
                    //console.log(files);
                },
                UploadProgress: function(up, file) {
                    $(".upload-scale").html("已上传：" + file.percent + "%");
                    $(".progress-bar").css("width", file.percent + "%");
                },
                FileUploaded: function(up, file, info) {
                    uploader.refresh();
                    var jsonData = info;
                    var jsonObj=JSON.parse(jsonData.response);
                    // console.log(file);
                    // console.log(info);
                    //console.log(jsonObj)
                    if(jsonObj==1){
                        $('#look').hide();
                        $('#content').val('');
                        alert("文件上传失败");
                        return false;
                    }else if(jsonObj==2){
                        $('#look').hide();
                        $('#content').val('');
                        alert("内容获取失败");
                        return false;
                    }else{
                        ue.setContent(jsonObj.html);
                        $('#title').val(decode( jsonObj.title ));
                        $('#lookview').show(); //暂时隐藏
                        $('#lookview2').show(); //暂时隐藏
                    }
                },
                Error: function(up, err) {
                    //console.log(up);
                    //console.log(err);
                    if(err.code==-600){
                        alert("您所上传的文件请小于5M");
                        return false;
                    }
                    if(err.code==-601){
                        alert("您所上传的文件类型有误");
                        return false;
                    }
                }
            }
        });
        uploader.init();
    });
    function submitbut() {
        var title=$('#title').val();
        var beizhu=$('#beizhu').val();
       if(title==""){
           alert("文字标题不能为空");
           return false;
       }
        $('#MyForm').submit();
    }
</script>
<div class="am-cf admin-main">
  <!-- sidebar start -->
  <{include file="public/member_main" /}>
  <!-- sidebar end -->
  <div class="admin-content content-article">
    <div class="admin-content-body">
      <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf am-btn-group">
          <button class="am-btn am-btn-primary am-btn-sm">发布媒体</button>
		  <a href="<{:url('wearticle/index')}>" class="am-btn am-btn-default am-btn-sm">发布自媒体</a> 
		  </div>
      </div>
      <hr>
    </div>
    <div class="page-content">
      <div class="page-content-area" style="margin-left: 3%;" >
      <form id="formlook" method="post" <{if condition="$AgencySiteInfo.Domain eq '-1'"}>action="/index/look"<{else}>action="<{:url("look")}>"<{/if}> target="_blank">
      <input type="hidden" name="opentitle" id="opentitle">
      <textarea style="display:none;" name="opencontent" id="opencontent"></textarea>
      <input type="hidden" name="openbeizhu" id="openbeizhu">
      </form>
      <form class="am-form" id="MyForm" method="post" action="<{:url("media")}>
        " >
        <div class="am-u-sm-12 am-u-md-1 am-md-text-right">上 传：</div>
        <div style="display: block; height: 32px; line-height: 32px;"> <span class="am-btn am-btn-primary am-btn-md" id="uploadstart">上传文档，支持DOCX格式，office2007,2010,2013,2016</span> <span style="color: red; padding-left: 10px;">请上传5M以内的文档</span>
          <input type="file" name="WordFile" id="container" style="display: none;">
          <div style="margin-left:10px;float: left; height: 32px; line-height: 32px;">
            <div class="progress-bar" style="height: 18px; margin-top: 6px;"></div>
          </div>
          <div style=" margin-left:10px;float: left; height: 32px; line-height: 32px;" role="progressbar">
            <div class="upload-scale"></div>
          </div>
        </div>
        <div class="am-g am-margin-top">
          <div class="am-u-sm-12 am-u-md-1 am-md-text-right">标 题：</div>
          <div class="am-u-sm-12 am-u-md-6" style="float:left;">
            <input id="title" type="text" class="am-input-sm" name="title" value="<{$title}>" autocomplete="off" placeholder="建议25字内,不要出现特殊字符,否则容易乱码">
            <span class="title_notice">建议与来源标题一致，避免产生纠纷（不保证一定使用来源标题或当前标题）</span> </div>
        </div>
        <div class="am-g am-margin-top" style="margin-top: 30px;">
          <div class="am-u-sm-12 am-u-md-1 am-md-text-right">内 容：</div>
          <textarea id="editorValue" name="editorValue" class="am-u-md-7" ><{$editorValue}></textarea>
        </div>
        <div class="am-g am-margin-top">
          <div class="am-u-sm-12 am-u-md-1 am-md-text-right" style="margin-top: 20px;">备 注：</div>
          <div class="am-u-sm-12 am-u-md-3" style="float: left;margin-top: 20px;">
			       <input id="title" type="text" class="am-u-md-3" name="beizhu" id="beizhu" value="<{$beizhu}>" autocomplete="off">
          </div>
        </div>
        <div class="am-g">
          <div class="am-u-sm-12 am-u-md-1 am-md-text-right" style="margin-top: 20px;">客 户：</div>
          <div class="am-u-sm-12 am-u-md-3" style="float: left;margin-top: 20px;">
            <input type="text" name="article_customer"  class="am-u-md-3" value="<{$article_customer}>" id="article_customer" autocomplete="off">
          </div>
        </div>
        <div class="am-g am-margin-top">
          <div class="am-u-sm-12 am-u-md-1 am-md-text-right">定 时：</div>
          <div class="am-u-sm-12 am-u-md-3" style="float: left;">
            <input type="text" value="<{$starttime}>" name="starttime" data-am-datepicker  id="starttime" autocomplete="off" class="am-u-md-3">
          </div>
        </div>
        <div style="margin: 20px 0 20px 30px; ">余 额<{$MemberBalanceCount}> 元 [第一步：填写标题、内容；点击下一步；选择要发布的媒体，提交订单，发布成功。 </div>
        <div style="margin: 20px 0px 60px 30px; display:block" >
          <button id="preview" type="button" class="am-btn am-btn-primary" onClick="look();">预览</button>
          <button type="button" class="am-btn am-btn-warning" onClick="submitbut();">下一步 选择媒体</button>
        </div>
        <div class="zhuyi">
          <input type="hidden" name="TempArticleID" value="<{:md5(mt_rand(100000,999999).'_'.time().'_'.mt_rand(100000,999999))}>">
          <div style="font-size: 16px; font-weight: bold;">发稿注意事项</div>
          <{$MainConfig.WebSiteNotes}></div>
      </form>
    </div>
  </div>
</div>
<{include file="public/member_footer" /}>
<script type="text/javascript">
    //UEditor placeholder
    UE.Editor.prototype.placeholder = function (justPlainText) {
        var _editor = this;
        _editor.addListener("focus", function () {
            var localHtml = _editor.getPlainTxt();
            if ($.trim(localHtml) === $.trim(justPlainText)) {
                _editor.setContent(" ");
            }
        });
        _editor.addListener("blur", function () {
            var localHtml = _editor.getContent();
            if (!localHtml) {
                _editor.setContent(justPlainText);
            }
        });
        _editor.ready(function () {
            _editor.fireEvent("blur");
        });
    };
    //var ue = UE.getEditor('content_desc');
    var ue = new UE.ui.Editor({initialFrameHeight:400});
        ue.render("editorValue");
		
        ue.ready(function() {
           ue.placeholder("稿件上传的3种方式：①上传文档 ②直接粘贴到内容栏进行编辑,内容里如果有图片请通过编辑器重新上传  ③用来源发稿的直接把来源链接放在内容栏.稿件一经发布，基本无法撤回和修改，一定要预览核对无误再提交哦！署名、作者名、免责声明等特殊内容不保证！与平台原有媒体信息和备注相矛盾的备注无效!");
         });

    function look() {
        var title=$('#title').val();
        $('#opentitle').val(title);
        var html = ue.getContent();
        $('#opencontent').val(html);
        $('#openbeizhu').val($('#beizhu').val());
        $('#formlook').submit();
    }
</script>
</body>
</html>
